import { OneModal } from '@/components/one-ui';
import { IOneModalRef } from '@/pages/type';
import { Ref, useRef } from 'react';

export const TipTextModal: React.FC<TipsErroAPI.ITipTextModal> = ({
  onClose, //关闭弹框
  configTestRes,
  tipTextColor = '#ff0003',
}) => {
  const testModalRef: Ref<IOneModalRef> = useRef(null); //弹框的ref
  /* 关闭弹窗 */
  const onCloseModal = () => {
    if (testModalRef) {
      if (testModalRef.current) {
        if (testModalRef.current.onModalCancel) {
          testModalRef.current.onModalCancel();
        }
      }
    }
  };
  return (
    <>
      <OneModal
        open={true}
        getContainer={false}
        ref={testModalRef}
        title={'提示'}
        width={document.body.clientWidth * 0.2}
        onCancel={onClose}
        bodyStyle={{
          padding: '15px 30px',
        }}
        centered
        onOk={onCloseModal}
      >
        <div
          style={{
            width: '100%',
            textAlign: 'center',
            fontSize: 18,
            color: tipTextColor,
          }}
        >
          {configTestRes}
        </div>
      </OneModal>
    </>
  );
};
